package cn.tedu._06interceptor.interceptors;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;

@Slf4j
public class MyInterceptor1 implements HandlerInterceptor {


    /**
     * 1.请求到达处理器之前的执行，可以做用户权限校验
     * @param request 请求对象
     * @param response  响应对象
     * @param handler   处理器方法
     * @return  true 放行，false 不放行
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
      log.debug("1.第一个拦截器 preHandle执行");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        log.debug("2.第一个拦截器 postHandle执行");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        log.debug("3.第一个拦截器 afterCompletion执行");
    }
}
